home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
xinu.arc
/
CTXSW.MAC
< prev
next >
Wrap
Text File
|
1985-09-13
|
3KB
|
124 lines
;
; C T X S W . M A C
;
; This program performs context switching for
; Xinu on Zilog Z-80 Micro's with Intel 8080 programs.
; (It does not store the Z-80 registers)
;
; Version 1.0 (Down and dirty)
; S. R. Sampson, September 1985
;
; The intent is to work with C/80(tm) Software Toolworks
; which does not produce Z-80 Op-codes
; and the Microsoft M80 assembler
;
; Called with pointers to old and new registers
;
; SP + 12 Old register pointer
; SP + 10 New register pointer
; SP + 8 Return Address
;
; Registers stored as:
;
; _______________________________
; | PC | SP | HL | DE | BC | AF |
; -------------------------------
;
;
CTXSW::
PUSH PSW ; SP + 6
PUSH B ; SP + 4
PUSH D ; SP + 2
PUSH H ; SP
LXI H,8
DAD SP
MOV C,M ; get return address into BC register
INX H ; non-destructively
MOV B,M
LXI H,12
DAD SP
MOV E,M ; get old register pointer into DE
INX H ; non-destructively
MOV D,M
XCHG ; then HL
MOV M,C
INX H
MOV M,B ; store return address as PC
INX H
SHLD POINT ; store pointer temporarily
LXI H,8 ; SP should not reflect registers pushed
DAD SP ; by this module
XCHG ; put SP into DE
LHLD POINT ; get old register pointer again
MOV M,E
INX H
MOV M,D ; store SP
INX H
SHLD POINT ; store the pointer
POP H
XCHG ; put HL in DE
LHLD POINT ; get old register pointer again
MOV M,E
INX H
MOV M,D ; store HL
INX H
SHLD POINT ; store the pointer
POP H
XCHG ; put DE into DE
LHLD POINT ; get old register pointer again
MOV M,E
INX H
MOV M,D ; store DE
INX H
SHLD POINT ; store the pointer
POP H
XCHG ; put BC into DE
LHLD POINT ; get old register pointer again
MOV M,E
INX H
MOV M,D ; store BC
INX H
SHLD POINT ; store the pointer
POP H
XCHG ; put AF into DE
LHLD POINT ; get old register pointer again (whew!)
MOV M,E
INX H
MOV M,D ; store AF
; SP now points at return address
LXI H,2 ; get new register pointer
DAD SP ; non-destructively
MOV E,M
INX H
MOV D,M
XCHG ; HL now points at new registers
INX H ; PC is not needed except for debugging
INX H ; HL now points at new SP
SPHL ; put stack pointer at new registers
.Z80
POP IX ; get new SP into IX
POP HL ; scoop out new registers
POP DE
POP BC
POP AF
LD SP,IX ; SP is now set up
.8080
EI
RET ; new process is ready
POINT: DW 0 ; temporary storage
END